package com.androidstartup.view;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.androidstartup.view.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class TargetOverlay extends Overlay {

	private static final int TARGET_HEIGHT = 32;
	private static final int TARGET_WIDTH = 32;
	
	private MapActivity mMap;
	private MapView mView;
    private Paint paint = new Paint();
   
    public TargetOverlay(MapActivity map) {
        mMap = map;
        mView = (MapView)map.findViewById(R.id.mapview);
    }

    public void draw(Canvas canvas, MapView map, boolean shadow) {
        super.draw(canvas, map, shadow);
        if(!shadow){
	        GeoPoint mapCenter = mView.getMapCenter();
        	Point screenCoords = mView.getProjection().toPixels(mapCenter, null);     
        	// Dibujar imagen en el centro de la pantalla
            Bitmap bmp = BitmapFactory.decodeResource(mMap.getResources(), R.drawable.target);            
            canvas.drawBitmap(bmp, screenCoords.x - TARGET_WIDTH/2, screenCoords.y - TARGET_HEIGHT/2, paint);
        }
    }
    
}
